<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 
 * @author: Marco Dennst�dt
 */



class Test extends TMT_Controller {
	
	public function index(){
		$result = "";
		$charPool = '0123456789abcdefghijklmnopqrstuvwxyz';
		for($p = 0; $p<15; $p++)
			$result .= $charPool[mt_rand(0,strlen($charPool)-1)];
		
		
		$training = Model\Training::find(1);
		echo $training->bill()->path;
		echo $training->offer()->path;
	}
        
        public function send_cal()
        {
            $this->headline = 'Mailversand!';
            $this->show_sidebar = FALSE;
            
            $iCal = $this->_generate_cal();
            
            require_once(BASEPATH.'../application/plugins/'."phpmailer/class.phpmailer.php");
            
            $mail = new PHPMailer();
            
            $mail->FromName = "TMT Admin";
            $mail->From = 'admin@tmt.com';
            $mail->Subject = 'TestMail';
            
            $recipients = array('felix.busch@t-systems.com');

            $mail->Body = 'Testmessage';
            $mail->AddStringAttachment($iCal, 'testmeeting.ics', "base64", "text/calendar");
            
            $this->_config_mail($mail, $recipients);
            
        }
        
        private function _generate_cal()
        {
            require_once('application/libraries/iCal.php');
            
            $myCal = new iCal();
            
            $myCal->set_organizer('Mongo', 'Mongo@kongo.de');
            $myCal->set_start('24.12.2012 23:00:00');
            $myCal->set_end('25.12.2012 12:00:00');
            $myCal->attendees = array('felix.busch@t-systems.com' => 'Felix Busch', 
                                      'lukas.fritsch@t-systems.com' => 'Lukas Fritsch',
                                      'jan.gilberg@t-systems.com' => 'Jan Gilberg');
            $myCal->method      = 'REQUEST';
            $myCal->summary     = 'Meine Zusammenfassung';
            $myCal->description = 'Eine Beschreibung';
            $myCal->location    = 'Darmstadt';
            

            return $myCal->generate();
        }
        

}
